
<template>
    <div>
        <h2>显示</h2>
        <input type="button" value="降序" @click="order(0)">
        <input type="button" value="升序" @click="order(1)">
        <input type="button" value="导出" @click="exporEx">
        <table border="1">
            <tr>
                <td>房价编号</td>
                <td>房型名称</td>
                <td>具体房价</td>
                <td>收款方式</td>
                <td>房量数量</td>
                <td>早餐份数</td>
                <td>操作</td>
            </tr>
            <tr v-for="item in list">
                <td>{{item.PId}}</td>
                <td>{{item.RName}}</td>
                <td>{{item.MyProPerty}}</td>
                <td>{{item.GetMoneyType==true?'预定付费':'到店付费'}}</td>
                <td>{{item.FNum}}</td>
                <td>{{item.BreakFirst}}</td>
                <td>
                    
                </td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import {useRouter} from 'vue-router'


let router=useRouter()

onMounted(()=>{
    getlist()
})

const list=ref([{
    PId:0,
    RName:0,
    MyProPerty:0,
    GetMoneyType:true,
    FNum:0,
    BreakFirst:0
}])


const getlist=()=>{
    axios.get('https://localhost:7231/api/Room/ShowRoomprice')
    .then(res=>{
        list.value=res.data
    })
    .catch(err=>{
        console.log(err)
    })
}

const order=(id:number)=>{
    axios.get('https://localhost:7231/api/Room/OrderByInfo',{
        params:{
            StateId:id
        }
    })
    .then(res=>{
        list.value=res.data
    })
    .catch(err=>{
        console.log(err)
    })
}

const exporEx=()=>{
    axios.get('https://localhost:7231/api/Room/ExportRoomPrice',{
        params:{
            PathName:'C:\\Users\\86137\\Desktop\\9.3zuoye\\价格导出.xlsx'
        }
    })
    .then(res=>{
        if(res.data>0){
            alert('导出成功')
        }
        else{
            alert("导出失败")
        }
    })

    
}


</script>

<style scoped>

</style>